<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript" src="js/js2.js" ></script>
	</head>
	<body>
		<script>
//			var f1=fn();
//			f1(15);

/**
			 * 闭包
			 * 导致局部变量k在执行结束后无法被系统回收,从而保留住局部变量;
			 * 回收需要手动清楚
			 */
			function makeCounter(){
				let k=0;
				return function(){
					return k++;
				};
			}
			const counter = makeCounter();  
			console.log(counter());
			console.log(counter());
			//
			var luo=(function(){
				var obj={};
				return {
					get(key){
						return obj[key];
					},
					set(key,value){
						obj[key]=value;
					}
				}
			}());
			
			luo.set('a',9);
			console.log(luo.get('a'));
		</script>
	</body>
</html>
